#ifndef _SYNCHRONIZED_DX_H_
#define _SYNCHRONIZED_DX_H_

#include <D3D9.h>
#include <D3dX9Core.h>
#include <interfacelib/Directx/initd3d.h>
#include <interfacelib/frame/usermessage.h>

namespace interfacelib
{
	namespace DirectX
	{
		class Synchronized_Update
		{
		public:
			Synchronized_Update();
			~Synchronized_Update();
		private:
			LPDIRECT3DDEVICE9 m_device;		
		};

		class Synchronized_Sprite
		{
		public:
			Synchronized_Sprite( DWORD mode = D3DXSPRITE_ALPHABLEND );
			~Synchronized_Sprite();
		private:
			LPD3DXSPRITE m_sprite;
			LPDIRECT3DDEVICE9 m_device;		
		};

		class Synchronized_Sprite_Rebegin
		{
		public:
			Synchronized_Sprite_Rebegin( DWORD mode = D3DXSPRITE_ALPHABLEND );
			~Synchronized_Sprite_Rebegin();
		private:
			LPD3DXSPRITE m_sprite;
			LPDIRECT3DDEVICE9 m_device;		
			DWORD m_mode;
		};

		class Synchronized_DX_VertexBuffer
		{
		public:
			Synchronized_DX_VertexBuffer( LPDIRECT3DVERTEXBUFFER9 vertexBuffer , int size );
			~Synchronized_DX_VertexBuffer();

			void *getVertices();
		private:
			LPDIRECT3DVERTEXBUFFER9 m_vertexBuffer;
			void *m_vertices;
		};


		class Synchronized_DX_TextureRect
		{
		public:
			Synchronized_DX_TextureRect( LPDIRECT3DTEXTURE9 texture );
			~Synchronized_DX_TextureRect();

			void *getBuffer();
			int getPitch();
		private:
			D3DLOCKED_RECT m_d3dLock;

			LPDIRECT3DTEXTURE9 m_texture;
		};
	}
}

#endif